<?php

use yii\db\Query;
use console\db\channels\TransferTableMigration;

/**
 * 用户融云token转移
 * 
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class m300000_000016_t_user_im extends TransferTableMigration {

    /**
     * @inheritdoc
     */
    public function buildQuery() {
        $columns = [
            'uid',
            'rongcloud',
        ];
        return (new Query())->from('{{%' . $this->sourceTable . '}}')->select($columns)->andWhere([
            'and',
            ['!=', 'rongcloud', ''],
            ['IS NOT', 'rongcloud', NULL],
        ]);
    }

    /**
     * @inheritdoc
     */
    public function getTransferOptions() {
        return [
            'table' => [
                'user_im' => 'member',
            ],
            'columns' => [
                'user_id' => 'uid',
                'im_token' => 'rongcloud',
            ]
        ];
    }

}
